/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 - 2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.csv.business.manager;

import java.io.File;
import java.util.List;

import com.genia.toolbox.basics.exception.BundledException;
import com.genia.toolbox.basics.exception.technical.TechnicalIOException;
import com.genia.toolbox.basics.exception.technical.XmlException;
import com.genia.toolbox.persistence.exception.PersistenceException;
import com.genia.toolbox.projects.csv.bean.CsvDataRow;
import com.genia.toolbox.projects.csv.bean.FolderDescriptor;
import com.genia.toolbox.projects.csv.bean.MappingDescriptor;
import com.genia.toolbox.projects.csv.business.exception.MappingException;

/**
 * interface for various process needed by the import manager.
 */
public interface CsvBackgroundProcess
{

  /**
   * value to input for column that belongs to a field of type like enumeration
   * must be specified exactly like it's described in the corresponding
   * properties file for the main language; so, a comment will be writen for
   * each enumeration column to specify the possible values for the concerned
   * language. this method is used to get all needed comments for all column of
   * the given folder.
   * 
   * @param folder
   *          the folder to consider
   * @return the {@link List} of comments to write to the csv file after the
   *         column names headers.
   * @throws MappingException
   *           if there is an error in the mapping.
   */
  public List<String> getNeededComments(FolderDescriptor folder)
      throws MappingException;



  /**
   * returns the name of the concrete column of the Cvs file associated to the
   * given folder.
   * 
   * @param folder
   *          the folder to consider
   * @return the name of the concrete column of the Cvs file associated to the
   *         given folder
   */
  public List<String> getColumnNames(FolderDescriptor folder);



  /**
   * generate the readme texts recommandation for folder dependencies.
   * 
   * @param mappingDescriptor
   *          the {@link MappingDescriptor} describing the mapping
   * @return a {@link List} of string texts.
   * @throws XmlException
   *           if an xml error occur
   * @throws TechnicalIOException
   *           if an io error occur
   */
  public List<String> getReadmeDependencies(MappingDescriptor mappingDescriptor)
      throws XmlException, TechnicalIOException;



  /**
   * save the configured supported languages in database.
   * 
   * @param mappingDescriptor
   *          the {@link MappingDescriptor} describing the mapping
   * @throws MappingException
   *           if a mapping error occur
   * @throws PersistenceException
   *           if a persistence error occur
   */
  public void saveSupportedLanguages(MappingDescriptor mappingDescriptor)
      throws MappingException, PersistenceException;



  /**
   * clean the database before importing new data version.
   * 
   * @param mappingDescriptor
   *          the {@link MappingDescriptor} describing the mapping
   * @throws PersistenceException
   *           if an error occur during the deletion process
   * @throws MappingException
   *           if a mapping error occur
   */
  public void clean(MappingDescriptor mappingDescriptor)
      throws PersistenceException, MappingException;



  /**
   * import the csv data rows for the given folder.
   * 
   * @param folderPath
   *          the file containing the data for the current folder
   * @param folder
   *          the concerned {@link FolderDescriptor}
   * @param acceptedDataRows
   *          a {@link List} of accepted {@link CsvDataRow}s of the folder,
   *          regarding to the considered file version
   * @throws BundledException
   *           if an error occured
   */
  public void importCsvDataRows(File folderPath, FolderDescriptor folder, List<CsvDataRow> acceptedDataRows)
      throws BundledException;

}
